﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
using Oxite;
using Oxite.Extensions;
using Oxite.Configuration;
using Oxite.Configuration.Extensions;
using Oxite.Infrastructure;
namespace ECube.Web.Home
{
    public class HomeModule : IOxiteModule,IOxiteDataProvider
    {
        private string urlPre = "Home";
        #region IOxiteModule 成员

        public void Initialize(OxiteModuleConfigurationElement module)
        {
           urlPre = module.Settings.ToNameValueCollection()["urlPre"] ?? urlPre;
        }

        public void Unload()
        {
            
        }

        public void RegisterRoutes(System.Web.Routing.RouteCollection routes)
        {
            string[] controllerNamespaces = new string[] { "ECube.Web.Home.Controllers" };
            urlPre = urlPre ?? "";
            if (!urlPre.Equals(string.Empty)) urlPre += "/";

            routes.MapRoute(
                "HomeIndex",
                urlPre,
                new { controller = "Home", action = "Index" },
                null,
                controllerNamespaces
                );
            
            routes.MapRoute(
                "HomeUser",
                urlPre + "{username}",
                new { controller = "Home", action = "UserIndex" },
                null,
                controllerNamespaces
                );
        }

        public void RegisterCatchAllRoutes(System.Web.Routing.RouteCollection routes)
        {
            
        }

        public void RegisterFilters(IFilterRegistry filterRegistry)
        {
            
        }

        public void RegisterModelBinders(System.Web.Mvc.ModelBinderDictionary modelBinders)
        {
           
        }

        public void RegisterWithContainer()
        {
           
        }

        #endregion

        #region IOxiteDataProvider 成员

        public void ConfigureProvider(OxiteConfigurationSection config, OxiteDataProviderConfigurationElement dataProviderConfig, Microsoft.Practices.Unity.IUnityContainer container)
        {
           // throw new NotImplementedException();
        }

        #endregion
    }
}
